package com.cloudream.core.controller;

import com.cloudream.core.entity.InfoEntity;
import com.cloudream.core.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

@Controller
public class IndexController {

    @Autowired
    InfoService infoService;

    @RequestMapping("/index")
    public Object index(Model model) {
        model.addAttribute("title", "展示页");
        model.addAttribute("content", "内容");
        return "home";
    }

    @RequestMapping("/get")
    @ResponseBody
    public Object get() {
        return infoService.getAll();
    }


    @RequestMapping("/add")
    @ResponseBody
    public Object add() {
        InfoEntity entity = new InfoEntity();
        entity.setAid(System.currentTimeMillis());
        return infoService.add(entity);
    }

}
